package de.iritgo.skillfull.entity.command;

import de.iritgo.skillfull.component.visitor.SimpleTextVisitor;
import de.iritgo.skillfull.entity.Command;
import de.iritgo.skillfull.entity.Entity;

public class SimpleTextCommand implements Command 
{
	private Entity entity;
	private boolean done;
	private SimpleTextVisitor simpleTextVisitor;
	
	public SimpleTextCommand (Entity entity, String text, float timeOnScreen, boolean blockNextCommand)
	{
		this.entity = entity;
		done = ! blockNextCommand;
		simpleTextVisitor = new SimpleTextVisitor (text, timeOnScreen); 
	}

	public String getName ()
	{
		return "SimpleText"; 
	}

	@Override
	public boolean canPerform () 
	{
		return true;
	}

	@Override
	public void perform (int delta) 
	{
		entity.accept (simpleTextVisitor);
		if (! done)
			done = simpleTextVisitor.isDone ();
	}
	
	@Override
	public void stop() 
	{
		done = true;
	}

	public Command getUndoCommand () 
	{
		return null;
	}

	@Override
	public boolean isDone () 
	{
		return done;
	}
}
